package com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb.converter;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.base.domain.mysql.cmdb.CmdbPartDetail;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb.FlowFormPartOutDetail;
import com.glsc.ngateway.common.base.domainmapper.cmdb.FlowFormPartOutMapper;
import com.glsc.ngateway.common.base.converter.platform.AbstractFlowFormDataConverter;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * 配件新增时流程子表domain到业务表domain转换（没有dto类）
 * @author zhengyr
 */
public class FlowFormPartOutConverter extends AbstractFlowFormDataConverter {
    
    public static CmdbPartDetail dto2Do(FlowFormPartOutDetail applyDto) {
        if (Objects.isNull(applyDto)) {
            return null;
        }
        CmdbPartDetail apply = FlowFormPartOutMapper.INSTANCE.dto2domain(applyDto);
        apply.setLocationId(Integer.valueOf(applyDto.getLocationId()));
        return apply;
    }

    public static List<CmdbPartDetail> dto2Do(List<FlowFormPartOutDetail> applyDtoList) {
        return CollectionUtils.isEmpty(applyDtoList) ? java.util.Collections.emptyList() : applyDtoList.stream().map(FlowFormPartOutConverter::dto2Do).collect(Collectors.toList());
    }

}
